<template>
  <div class="child">
    <h2>子组件</h2>
    <h4>玩具: {{ toy }}</h4>
    <button @click="emitter.emit('getToy', toy)">传递玩具给弟弟</button>
  </div>
</template>

<script setup lang="ts">
import {ref} from 'vue'
import emitter from '@/utils/emitter';
let toy = ref('奥特曼')

// 给emitter触发事件
setTimeout(()=>{
  emitter.emit('getToy', toy.value)
},2000)


</script>

<style>
  .child {
    background: pink;
  }
</style>